package com.itheima.service.impl;


import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.itheima.dao.CheckItemDao;
import com.itheima.entity.QueryPageBean;
import com.itheima.pojo.CheckItem;
import com.itheima.service.CheckItemService;
import org.apache.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * 检查服务
 *
 * @create 2020/11/16 0016 11:32
 */
@Service
@Transactional
public class CheckItemServiceImpl implements CheckItemService {
    
    //注入CheckItemDao对象
    @Autowired
    private CheckItemDao checkItemDao;
    
    /**
     * 增加检查项
     *
     * @param checkItem
     */
    @Override
    public void add(CheckItem checkItem) {
        checkItemDao.add(checkItem);
    }
    
    /**
     * 删除检查项
     *
     * @param id
     */
    @Override
    public void delete(Integer id) {
        checkItemDao.deleteById(id);
    }
    
    /**
     * 修改检查项
     *
     * @param checkItem
     */
    @Override
    public void edit(CheckItem checkItem) {
        checkItemDao.edit(checkItem);
    }
    
    /**
     * 分页-条件查询检查项
     *
     * @param queryPageBean
     * @return
     */
    @Override
    public PageInfo<CheckItem> selectByCondition(QueryPageBean queryPageBean) {
        PageHelper.startPage(queryPageBean.getCurrentPage(), queryPageBean.getPageSize());
        List<CheckItem> all = checkItemDao.selectByCondition(queryPageBean.getQueryString());
        return new PageInfo(all);
        
    }
    
    /**
     * 根据id查询检查项
     *
     * @param id
     * @return
     */
    @Override
    public CheckItem findById(Integer id) {
        return checkItemDao.findById(id);
    }
    
    @Override
    public List<CheckItem> findAll() {
        return checkItemDao.findAll();
    }
}
